package com.yilijk.base.databinding;

import android.widget.ImageView;

import androidx.databinding.BindingAdapter;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.yilijk.base.AppBase;
import com.yilijk.base.R;
import com.yilijk.base.utils.ALog;

public class DataBindingHelper {

    @BindingAdapter("imagecircle")
    public static void setImageCircle(ImageView image,String url){
        ALog.e(url);
        Glide.with(AppBase.getApplication())
                .load(url)
                .transform(new CenterCrop(),new CircleCrop())
                .error(R.drawable.img_error)
                .into(image);
    }

    @BindingAdapter("imagesquare")
    public static void setImageSquare(ImageView image,String url){
        ALog.e(url);
        Glide.with(AppBase.getApplication())
                .load(url)
                .transform(new CenterCrop())
                .error(R.drawable.img_error)
                .into(image);
    }

    @BindingAdapter("imageUrl")
    public static void setImageUrl(ImageView image,String url){
        ALog.e(url);
        Glide.with(AppBase.getApplication())
                .load(url)
                .transform(new CenterCrop())
//                .error(R.drawable.img_error)
                .into(image);
    }

    @BindingAdapter("imageUrlNormal")
    public static void setImageUrlNormal(ImageView image,String url){
        ALog.e(url);
        Glide.with(AppBase.getApplication())
                .load(url)
//                .error(R.drawable.img_error)
                .into(image);
    }

}
